package org.xm.sk.vo.tb;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.xm.sk.vo.Base;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "dc_mete")
@ApiModel(value = "Mete", parent = Base.class, description = "评论")
public class Mete extends Base {

    /**
     * 
     */
    private static final long serialVersionUID = -2221119452608537888L;

    @ApiModelProperty(value = "评论标题")
    @Column(length = 255)
    private String name;

    @ApiModelProperty(value = "评论内容")
    @Column
    private String comment;

    @ApiModelProperty(value = "评分")
    @Column
    private Integer mark;

    @ApiModelProperty(value = "评论图片")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinTable(name = "dc_mete_image", joinColumns = {
            @JoinColumn(name = "dc_mete_id") }, inverseJoinColumns = {
                    @JoinColumn(name = "dc_image_id") })
    @Fetch(FetchMode.SUBSELECT)
    private Set<Image> images = new HashSet<Image>(0);
    
    @ApiModelProperty(value = "评论的门店")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinTable(name = "dc_shop_mete", joinColumns = {
            @JoinColumn(name = "dc_mete_id") }, inverseJoinColumns = {
                    @JoinColumn(name = "dc_shop_id") })
    @Fetch(FetchMode.SUBSELECT)
    private Set<Shop> shops = new HashSet<Shop>(0);

    @ApiModelProperty(value = "评论门店ID")
    @Transient
    private Integer shopId;
    
    @ApiModelProperty(value = "评论门店名称")
    @Transient
    private String shopName;

    @ApiModelProperty(value = "评论的发型师")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinTable(name = "dc_hairdresser_mete", joinColumns = {
            @JoinColumn(name = "dc_mete_id") }, inverseJoinColumns = {
                    @JoinColumn(name = "dc_hairdresser_id") })
    @Fetch(FetchMode.SUBSELECT)
    private Set<Hairdresser> hairdressers = new HashSet<Hairdresser>(0);

    @ApiModelProperty(value = "评论发型师ID")
    @Transient
    private Integer hairdresserId;
    
    @ApiModelProperty(value = "评论发型师名称")
    @Transient
    private String hairdresserName;

    @ApiModelProperty(value = "评论发型师所属门店ID")
    @Transient
    private Integer hShopId;
    
    @ApiModelProperty(value = "评论发型师所属门店名称")
    @Transient
    private String hShopName;

    @ApiModelProperty(value = "关联订单")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_order_id")
    private Boder boder;

    @ApiModelProperty(value = "关联订单ID")
    @Transient
    private Integer boderId;
    
    @ApiModelProperty(value = "评论作者")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_user_id")
    private User user;
    
}
